let path = require('path');
let webpack = require('webpack');
let HtmlWebpackPlugin = require('html-webpack-plugin');
let ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
let lessExtract = new ExtractTextWebpackPlugin("less.less");
let isDev = process.env.NODE_ENV === 'development';
let CleanWebapckPlugin = require("clean-webpack-plugin");


module.exports = {
    entry: "./src/index.js",//入口
    mode: 'development',//开发模式
    output: { //出口
        filename: 'app.[hash:8].js',
        path: path.join(__dirname, 'dist')
    },
    // 更新环境变量
    module: {
        rules: [

        ]
    },
    //插件的配置
    plugins: [
        lessExtract,
        //打包前先删除一下
        new CleanWebapckPlugin(['dist']),
        //打包html的文件
        new HtmlWebpackPlugin({
            filename: 'index.html',
            template: './src/index.html',
            title: "练习一下",
            hash: true,
            // minify:{
            //     removeAttributeQuotes:true,  //去双引号
            //     collapseWhitespace:true,//在一行
            // }
        }),
    ],
    //服务的配置
    devServer: {
        contentBase: './dist',
        port: 6666,
        hot: true, // 使用热更新
        compress: true //服务器压缩
    }
}
// webpack  html 打包到build下可以自动引入js --  html-webpack-plugin